/**
 * Created by 小敏哥 on 2017/8/25.
 */
import {UPLOAD_RESULT} from './actionsTypes';
import {Toast} from 'antd-mobile';
import uploadService from '../services/uploadService';

export const uploadResult = data => ({type: UPLOAD_RESULT, data: data}); //上传结果

//获取上传结果
export const getUploadResult = (data,callBack) => {
    return (dispatch, getState) => {
        Toast.hide();
        Toast.loading("", 30, () => Toast.info("网络错误", 2));
        uploadService.getUploadResult(data).then((result) => {
            Toast.hide();
            if (result.code == '1000') {
                dispatch(uploadResult(result.data));
                callBack(result.data);
            }
            else{
                Toast.info(resultData.msg, 2);
            }
        }).catch(() => {
            Toast.info("获取数据出错", 2);
        });
    }
};